package java_thinking.unit_18_IO._18_6;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.ListIterator;

/**
 * @Desc:   修改E08，将行号一同写进文件
 * @author: cww
 * @DateTime: 2019/5/14 20:00
 */

public class E12_LineNumber {
    public static void main(String[] args) throws IOException {
        List<String> list = E07_FileIntoList.read("src/maindemo/java/java_thinking/unit_18_IO/_18_6/E12_LineNumber.java");
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("src/maindemo/java/java_thinking/unit_18_IO/_18_6/FileOutPutShortcut1.txt")));
        int line = list.size();
        for (ListIterator<String> it = list.listIterator(list.size());it.hasPrevious();) {
            System.out.println(line-- + ": " + it.previous());
        }
        out.close();
    }
}
